package com.bilibili.juc.set;

import java.util.NavigableSet;
import java.util.concurrent.ConcurrentSkipListSet;

public class ConcurrentSkipListSetDemo3 {
    public static void main(String[] args) {
        ConcurrentSkipListSet<Integer> skipListSet = new ConcurrentSkipListSet<>();
        skipListSet.add(300);
        skipListSet.add(215);
        skipListSet.add(345);
        skipListSet.add(10);
        skipListSet.add(9);
        skipListSet.add(20);
        skipListSet.add(7);
        System.out.println(skipListSet); //[7, 9, 10, 20, 215, 300, 345]

        // 返回此set的部分视图，其元素大于或等于 fromElement 。
        NavigableSet<Integer> tailSet = skipListSet.tailSet(215);
        System.out.println(tailSet); //[215, 300, 345]

        NavigableSet<Integer> headSet = skipListSet.headSet(10, true);
        System.out.println(headSet);
    }
}
